﻿using Jay.Sc2.Bof.Lib.State;

namespace Jay.Sc2.Bof.Lib.Action.Terran
{
	public abstract class ActionUpgradeFromBarracksTechLab : ActionUpgradeFromTerran
	{
		public ActionUpgradeFromBarracksTechLab(int researchTime, int minerals, int gas) : base(researchTime, minerals, gas) { }

		public override TerranState.TerranProductionBuilding GetProductionBuilding(TerranState state) { return state.BarracksTechLab; }

		public override IAction[,] Requirements
		{
			get
			{
				if (m_Requirements == null)
				{
					m_Requirements = new IAction[,] { 
						{ ActionProduceTechLabOnBarracks.Instance }, 
						{ ActionSwitchTechLabFromFactoryToBarracks.Instance }, 
						{ ActionSwitchTechLabFromStarportToBarracks.Instance }, 
					};
				}
				return m_Requirements;
			}
		}
	}
	public class ActionUpgradeCombatShield : ActionUpgradeFromBarracksTechLab
	{
		public static ActionUpgradeCombatShield Instance = new ActionUpgradeCombatShield();

		private ActionUpgradeCombatShield() : base(110, 100, 100) { }

		public override TerranState.TerranUpgrade GetUpgrade(TerranState state) { return state.CombatShield; }
		public override string EventName { get { return "ActionResearchedCombatShield"; } }
	}
	public class ActionUpgradeStimpack : ActionUpgradeFromBarracksTechLab
	{
		public static ActionUpgradeStimpack Instance = new ActionUpgradeStimpack();

		private ActionUpgradeStimpack() : base(140, 100, 100) { }

		public override TerranState.TerranUpgrade GetUpgrade(TerranState state) { return state.Stimpack; }
		public override string EventName { get { return "ActionResearchedStimpack"; } }
	}
	public class ActionUpgradeConcussiveShells : ActionUpgradeFromBarracksTechLab
	{
		public static ActionUpgradeConcussiveShells Instance = new ActionUpgradeConcussiveShells();

		private ActionUpgradeConcussiveShells() : base(60, 50, 50) { }

		public override TerranState.TerranUpgrade GetUpgrade(TerranState state) { return state.ConcussiveShells; }
		public override string EventName { get { return "ActionResearchedConcussiveShells"; } }
	}
	public class ActionUpgradeNitroPacks : ActionUpgradeFromBarracksTechLab
	{
		public static ActionUpgradeNitroPacks Instance = new ActionUpgradeNitroPacks();

		private ActionUpgradeNitroPacks() : base(100, 50, 50) { }

		public override TerranState.TerranUpgrade GetUpgrade(TerranState state) { return state.NitroPacks; }
		public override string EventName { get { return "ActionResearchedNitroPacks"; } }
		public override bool IsInvalid(IBuildOrder bo)
		{
			TerranState state = bo.State as TerranState;
			return base.IsInvalid(bo) || (state.Factory.Total + state.FactoryReactor.Total + state.FactoryTechLab.Total == 0);
		}
		public override IAction[,] Requirements
		{
			get
			{
				if (m_Requirements == null)
					m_Requirements = new IAction[,] {
						{ ActionProduceTechLabOnBarracks.Instance, ActionProduceFactory.Instance },
						{ ActionSwitchReactorFromFactoryToBarracks.Instance, ActionProduceFactory.Instance },
						{ ActionSwitchReactorFromStarportToBarracks.Instance, ActionProduceFactory.Instance },
					};
				return m_Requirements;
			}
		}
	}
}
